package com.youhome.utils;

import org.modelmapper.ModelMapper;
import org.modelmapper.TypeToken;

import java.lang.reflect.Type;
import java.util.List;

/**
 * Created by chen365 on 2019/04/28.
 */
public class ModelMapperUtils {

    public static <T> Object toBean(Object object, Class<T> beanClass) {
        ModelMapper mapper = new ModelMapper();
        try {
            return mapper.map(object, beanClass);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static <T> List<T> toList(Object object, Type type) {
        ModelMapper mapper = new ModelMapper();
        try {
            return mapper.map(object, type);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
